<template>
  <el-container>
    <el-card class="box-card-wrap">
      <el-main style="padding: 10px !important;">
        <el-row :gutter="20">
          <el-tabs v-model="activeName" type="border-card" @tab-click="handleClick">
            <el-tab-pane v-for="(item, index) in checkTypeData" :name="item.typeCode" :label="item.type"></el-tab-pane>
            <el-col :span="4" v-for="(item, index) in dataList" :key="index">
              <div class="grid-content bg-purple">
                <el-card class="box-card">
                  <div slot="header" class="header">
                    <!-- class="left" -->
                    <!-- class="right" -->
                    <div style="font-size: 14px;">医院：{{ item.deptName }}</div>
                    <div style="margin-top: 10px;font-size: 14px;">日期：{{ item.checkDate }}</div>
                  </div>
                  <div class="img-wrap">
                    <el-image :preview-src-list="[item.picture]" :src="item.picture" style="width: 100%; height: 100%">
                      <div slot="placeholder" class="image-slot">
                        加载中<span class="dot">...</span>
                      </div>
                    </el-image>
                  </div>
                </el-card>
              </div>
            </el-col>
          </el-tabs>


        </el-row>
      </el-main>
      <el-footer>
        <div class="block">
          <el-pagination class="pageStyle" background @size-change="handleSizeChange"
            @current-change="handleCurrentChange" :current-page="page.currentPage" :page-sizes="page.pageSizes"
            :page-size="page.pageSize" layout="total,  prev, pager, next, jumper" :total="page.total">
          </el-pagination>
        </div>
      </el-footer>
    </el-card>
  </el-container>
</template>
<script>
import {
  getList, getCheckType
} from "@/api/infoManagement/diagnosticRecordReport";
export default {
  data() {
    return {
      checkTypeData: [],
      id: '',
      page: {
        pageSize: 12,
        currentPage: 1,
        total: 0,
        pageSizes: [12, 24, 36, 48],
      },
      activeName: '',
      dataList: ''
      // dataList: [{
      //   name: '第四医院',
      //   id: 1,
      //   time: '2023/3/8',
      //   picture: '/img/chufang1.jpg'
      // },]


    }

  },
  created() {
    this.id = this.$route.query.id
    getCheckType({
      patientId: this.id
    }).then((res) => {
      const data = res.data.data
      this.checkTypeData = data
      this.activeName = this.checkTypeData && this.checkTypeData[0].typeCode
      this.onLoad(this.page)
    })

  },
  methods: {
    handleSizeChange(val) {
      this.page.currentPage = 1
      this.page.pageSize = val
      this.onLoad(this.page, this.query)
    },
    handleCurrentChange(val) {
      this.page.currentPage = val
      this.onLoad(this.page, this.query)
    },
    onLoad(page, params = {}) {
      this.loading = true;
      getList(page.currentPage, page.pageSize, Object.assign(params, this.query, {
        typeCode: this.activeName,
        patientId: this.id
      })).then(res => {
        const data = res.data.data;
        this.page.total = data.total;
        this.dataList = data.records;
        this.loading = false;
        // this.selectionClear();
      });
    },
    handleClick(tab, event) {
      this.onLoad(this.page)
    }
  }
}
</script>
<style scoped lang="scss">
.img-wrap {
  height: 220px;
  width: 100%;
}

// .header {
// position: relative;
// top: 10px;
// height: 40px;

// .left {
//   position: absolute;
//   left: 5px;
// }

// .right {
//   position: absolute;
//   right: 5px;
// }
// }
</style>
<style>
.box-card-wrap {
  width: 100%;
  height: 100%;
}

.el-row {
  margin-bottom: 20px;

  &:last-child {
    margin-bottom: 0;
  }
}

.el-col {
  border-radius: 4px;
}

.bg-purple-dark {
  background: #99a9bf;
}

.bg-purple {
  background: #d3dce6;
}

.bg-purple-light {
  background: #e5e9f2;
}

.grid-content {
  border-radius: 4px;
  min-height: 36px;
}

.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}
</style>